/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.util.perifericos;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Usuario
 */
public class ImpresoraTickets {
    
    
    public static void imprimir(StringBuffer s){
      
        FileOutputStream os =null;
        try {
        
            os = new FileOutputStream("COM6:");
            PrintStream ps = new PrintStream(os);
            ps.println(s); 
            ps.close();
            
            // imprimir corte
            FileWriter imp = new FileWriter("COM6");
            imp.write(29);
            imp.write(86);
            imp.write(66);
            imp.write(3);
            imp.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(ImpresoraTickets.class.getName()).log(Level.SEVERE, null, ex);
        } 
        catch(Exception e){
            Logger.getLogger(ImpresoraTickets.class.getName()).log(Level.SEVERE, null, e);
        }
            finally {
            try {
                os.close();
            } catch (IOException ex) {
                Logger.getLogger(ImpresoraTickets.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
}
